package com.rtf.framework.timertask.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;

/**
 * xxljob插件配置管理.
 *
 * @ClassName:  XxljobConfig
 * @author: sfl
 * @date:   2020-11-18 20:32:48
 * @since:  v1.0
 */
@Configuration
@EnableConfigurationProperties(XxljobProperties.class)
public class XxljobConfig {

	@Bean
	public XxlJobSpringExecutor xxlJobSpringExecutor(XxljobProperties properties) throws Exception {

		XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
		xxlJobSpringExecutor.setAdminAddresses(properties.getAdminAddresses());
		xxlJobSpringExecutor.setAppname(properties.getAppName());
		xxlJobSpringExecutor.setIp(properties.getIp());
		xxlJobSpringExecutor.setPort(properties.getPort());
		xxlJobSpringExecutor.setAccessToken(properties.getAccessToken());
		xxlJobSpringExecutor.setLogPath(properties.getLogPath());
		xxlJobSpringExecutor.setLogRetentionDays(properties.getLogRetentionDays());
		return xxlJobSpringExecutor;
	}
}
